package com.cn.wanxi.service.impl;

import com.cn.wanxi.entity.UserEntity;
import com.cn.wanxi.mapper.UserMapper;
import com.cn.wanxi.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements IUserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public List<UserEntity> findAll() {
        return userMapper.findAll();
    }

    @Override
    public String login(UserEntity userEntity) {
        if (userEntity.getCode().equals(userEntity.getSessionCode())) {
//            UserDao userDao = new UserImpl();
            //        判断是否输入的用户名和密码正确
            UserEntity model = userMapper.findByUsernameAndPassword(userEntity);
            if (model == null) {
                return "error";
            } else {
                return "success";
            }

        } else {
            return "error-code";
        }

    }
}
